           package com.java.diagnostics.visualizer.impl.sources.implementations;
           
           import com.java.diagnostics.visualizer.exceptions.GCAndMemoryVisualizerException;
           import com.java.diagnostics.visualizer.impl.sources.SourceImpl;
           import java.io.ByteArrayInputStream;
           import java.io.InputStream;
           
           public class TextSourceImpl extends SourceImpl
           {
             private static final int BYTES_PER_CHARACTER = 2;
             private String text;
             private boolean hasChanged = true;
           
             public TextSourceImpl(String name, String text) {
               super(name);
               this.text = text;
             }
           
             public String getText() throws GCAndMemoryVisualizerException
             {
               this.hasChanged = false;
               return this.text;
             }
           
             public InputStream getRawStream() throws GCAndMemoryVisualizerException {
               this.hasChanged = false;
               InputStream stream = new ByteArrayInputStream(this.text.getBytes());
           
               return stream;
             }
           
             public boolean hasChangedSinceLastGet()
             {
               return this.hasChanged;
             }
           
             public boolean containsWithinReasonableDistanceOfStart(String target) {
               this.hasChanged = false;
               return this.text.indexOf(target) > -1;
             }
           
             public boolean containsWithinReasonableDistanceOfStart(String[] targets) {
               for (String target : targets) {
                 if (containsWithinReasonableDistanceOfStart(target)) {
                   return true;
                 }
               }
               return false;
             }
           
             public long getApproximateSize()
               throws GCAndMemoryVisualizerException
             {
               return this.text.length() * 2;
             }
           }

